package io.github.talelin.latticy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.github.talelin.latticy.common.mybatis.Page;
import io.github.talelin.latticy.mapper.CustomerMapper;
import io.github.talelin.latticy.model.Customer;
import io.github.talelin.latticy.service.CustomerService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author generator@TaleLin
 * @since 2021-11-30
 */
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {


    @Override
    public IPage<Customer> paging(Long pageNum, Long pageSize) {
        Page<Customer> page = new Page<>(pageNum, pageSize);
        return this.baseMapper.selectPage(page, null);
    }

    @Override
    public IPage<Customer> search(Long pageNum, Long pageSize, String keyword) {
        Page<Customer> page = new Page<>(pageNum, pageSize);
        QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("nickname", keyword);
        return this.baseMapper.selectPage(page, queryWrapper);
    }
}
